import { ref } from "vue"
import { onPageScroll } from "@dcloudio/uni-app"

export function usePageScrollTop(callback?: (scrollTop: number) => void) {
	const scrollTop = ref(0)

	// 监听页面滚动
	onPageScroll(({ scrollTop: top }) => {
		scrollTop.value = top
		callback?.(top)
	})

	return {
		scrollTop,
	}
}
